package lib

func init() {
	Probs = append(Probs, Problem{
		Num:         121,
		Discription: "单笔股票买卖最大收益",
		Level:       1,
		Labels: map[string]int{
			"双指针滑动": 1,
		},
	})
}

func MaxProfit(prices []int) int {
	maxProfit := 0
	minPrice := prices[0]
	for i := 1; i < len(prices); i++ {
		minPrice = min(minPrice, prices[i])
		maxProfit = max(maxProfit, prices[i]-minPrice)
	}

	return maxProfit
}
